package account_dao

import (
	db_util "app/app_src/framework/db/util"
	account_dto "app/app_src/modules/account/dto"
)

// 根据用户名获取用户信息
func GetUserDalDtoByUserName(userName string) *account_dto.UserDalDTO {
	db := db_util.MustGetDB()
	defer db.Close()

	users := []account_dto.UserDalDTO{}
	err := db.Select(&users, "select * from sys_user where user_name = ?", userName)
	if err != nil {
		panic(err)
	}

	if len(users) > 0 {
		return &users[0]
	}

	return nil
}
